package com.hice.demo.java.concurrent;

import java.util.concurrent.ConcurrentNavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;

/**
 * @author hyson
 * @create 2017-03-13 11:41
 */
public class ConcurrentNavigableMapDemo {

    public static void main(String[] args) {
        ConcurrentNavigableMap map = new ConcurrentSkipListMap();
        map.put("1", "one");
        map.put("2", "two");
        map.put("3", "three");
        ConcurrentNavigableMap headMap = map.headMap("2");
        System.out.println("headMap-->" + headMap.toString());

        ConcurrentNavigableMap tailMap = map.tailMap("2");
        System.out.println("tailMap-->" + tailMap.toString());

        //subMap() 方法返回原始 map 中，键介于 from(包含) 和 to (不包含) 之间的子 map
        ConcurrentNavigableMap subMap = map.subMap("2", "3");
        System.out.println("subMap-->" + subMap.toString());
    }
}
